package com.thwj.project.app.api;

import com.thwj.framework.web.domain.R;
import com.thwj.framework.web.service.TokenService;
import com.thwj.project.app.api.param.ChatRoomParam;
import com.thwj.project.app.api.vo.ChatroomContentVo;
import com.thwj.project.app.api.vo.ChatroomVo;
import com.thwj.project.app.service.AppChatRoomService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@Api(tags="app 聊天室相关接口")
@RestController
@RequestMapping("/app/chat")
public class AppChatRoomController {


    @Autowired
    private TokenService tokenService;
    @Autowired
    AppChatRoomService appChatRoomService;


    @ApiOperation(value = "发送内容",notes = "发送内容")
    @PostMapping("/commitChatContent")
    public R<String> commitChatContent(@RequestBody ChatRoomParam chatRoomParam) {
        appChatRoomService.commitChatContent(chatRoomParam, tokenService.getLoginUser());
        return R.data("发送成功");
    }

    @ApiOperation(value = "不同的用户进入这个聊天室 是不一样的 需要下发这个配置",notes = "")
    @GetMapping("/getChatroomConfig")
    public R<ChatroomVo> getChatroomVoConfig(@RequestParam Long activityId) {
        ChatroomVo chatroomVo = appChatRoomService.getChatroomVoConfig(activityId, tokenService.getLoginUser());
        return R.data(chatroomVo);
    }
    @ApiOperation(value = "获取聊天室内容列表 所有数据",notes = "获取聊天室内容列表 所有数据")
    @GetMapping("/getChatroomContentVoList")
    public R<List<ChatroomContentVo>> getChatroomContentVoList(@RequestParam Long activityId) {
        List<ChatroomContentVo> contentVoList = appChatRoomService.getChatroomContentVoList(activityId, tokenService.getLoginUser());
        return R.data(contentVoList);
    }

    @ApiOperation(value = "呼叫客服",notes = "呼叫客服 发送模板消息到 指定的人 只需要传 活动id即可")
    @PostMapping("/commitCallKefu")
    public R<String> commitCallKefu(@RequestBody ChatRoomParam chatRoomParam) {
        appChatRoomService.commitCallKefu(chatRoomParam, tokenService.getLoginUser());
        return R.data("发送成功");
    }

    @ApiOperation(value = "参与人确认到场",notes = "")
    @PostMapping("/commitUser2Confirm")
    public R<String> commitUser2Confirm(@RequestBody ChatRoomParam chatRoomParam) {
        appChatRoomService.commitUser2Confirm(chatRoomParam, tokenService.getLoginUser());
        return R.data("操作成功");
    }

}
